package com.xk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xk.domain.ResponseResult;
import com.xk.domain.entity.Article;
import com.xk.enums.AppHttpCodeEnum;
import com.xk.mapper.ArticleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xk.service.ArticleService;

import java.util.List;

/**
 * 文章表(Article)表服务实现类
 *
 * @author makejava
 * @since 2024-07-18 23:18:12
 */
@Service("articleService")
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;
    @Override
    public ResponseResult hotArticleList() {
        QueryWrapper<Article> select = new QueryWrapper<Article>()
                .orderByDesc("view_count")
                .select("id", "title", "view_count");
        List<Article> articles = articleMapper.selectList(select);
        ResponseResult responseResult = ResponseResult.okResult(articles);
        return responseResult;

    }
}

